package demo.properties;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Properties;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

public class PropTest {
	static{
		String relativePath="/properties/log4j_prop.properties";
		InputStream in=PropTest.class.getResourceAsStream(relativePath);
		URL url=PropTest.class.getResource(relativePath);
		System.out.println(url);
		Properties properties=new Properties();
		try {
			properties.load(in);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		PropertyConfigurator.configure(properties);
	}
	private static Logger logger=Logger.getLogger(PropTest.class);
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		  // 记录debug级别的信息  
        logger.debug("This is debug message.");  
        // 记录info级别的信息  
        logger.info("This is info message.");  
        // 记录error级别的信息  
        logger.error("This is error message.");  
	}

}
